<extend name="Public:template" />
<block name="page_header">
</block>
<block name="page_body">
<!-- 购物车页面  -->
<header class="headerSub clearfix">
    <h2>完善个人信息</h2>
    <a href="#" class="backBtn leftBtn" onClick="javascript:window.history.back(-1);return false;">返回上页</a>
    <a href="{:U('CustPassport/index')}" class="rightBtn yellowNorBg">我的小屋</span></a>
</header>
<div class="content">
	<div class="listFormBox">
		<dl id="address" class="itemFormBox">
			<dd class="<notempty name='list'>none</notempty>">
				<span id="err_info" class="errHolder" style="display:none;"></span>
				<form action="{:U('CustPassport/doUpd')}" name="form_edit" id="form_edit">
					<ul class="inputBox">
						<li><input  name="name" type="text" class="inputIconUser" placeholder="用户名称/昵称" value="{$cust.name}"/> </li>
						<li>
							<input  name="sex" type="radio" value="先生" <if condition="$cust.sex eq '先生'">checked</if> >先生 &nbsp; &nbsp; &nbsp; &nbsp;
							<input  name="sex" type="radio" value="女士" <if condition="$cust.sex eq '女士'">checked</if> >女士
						</li>
						<li>
							<select id="shop_id" name="shop_id" onChange="changeShop()" style="width:100%;height:100%;vertical-align:middle;">
								<option value="">选择离您家最近的配送点</option>
								<volist name="shopList" id="val">
								<option value="{$val.id}" id="deliver{$val.id}" deliver_around="{$val.deliver_around}">{$val.district} {$val.address}</option>
								</volist>
							</select>
						</li>
						<span id="deliver_around"></span>
					</ul>
					<ul class="linkBtnBox">
						<li class="linkBtnBoxFull"><a href="#" class="linkBtn greenNorBg" id="doUpdBtn">修改</a></li>
					</ul>
				</form>
			</dd>
		</dl>
	</div>
</div>
</block>
<block name="script_footer">
<script type="text/javascript">
$(document).ready(function(){
	$("#doUpdBtn").on( "click", function() {
		$("#err_info").hide();
		$.ajax({
	        'url': $("#form_edit").attr("action"),
	        'type':"post",
	        'dataType': "json",
	        'data': $('#form_edit').serialize(),
	        'success': function (data) {
	        	var error = data['error'];
	        	var message = data['message'];
	        	$("#err_info").html(message);
        		$("#err_info").show();
	        	if(error=='0'){
	        		alert(message);
	        		document.location.href="/Cust/index.html"; 
	        	}
	        }
	    });
	});
})

function changeShop(){
	// $("#ddlRegType").find("option:selected").text();
	var shop_id = $("#shop_id").val();
	if(shop_id!=''){
		$("#deliver_around").html("配送范围："+$("#deliver"+shop_id).attr("deliver_around"));
	}else{
		$("#deliver_around").html("如果配送地址没有覆盖您的区域，请联系我们的客服");
	}

}
</script>
</block>